﻿using System;
using System.ComponentModel;


namespace advadev.Windows.DragDrop.Demo
{

    /// <summary>
    /// Represents a demo model item
    /// </summary>
    public class DemoModelItem : INotifyPropertyChanged
    {

        /// <summary>for internal use</summary>
        private int _counter = 10;


        /// <summary>
        /// Initializes a new instance of the DemoModelItem class
        /// </summary>
        public DemoModelItem()
        {
        }


        /// <summary>
        /// Gets or sets the counter
        /// </summary>
        public int Counter
        {
            get
            {
                return _counter;
            }
            set
            {
                if (value != _counter)
                {
                    _counter = value;
                    OnPropertyChanged("Counter");
                }
            }
        }


        #region INotifyPropertyChanged implementation
        /// <summary>for internal use</summary>
        private event PropertyChangedEventHandler _propertyChanged;

        /// <summary>
        /// Handles the "property changed" event
        /// </summary>
        /// <param name="propertyName">
        /// Name of the changed property
        /// </param>
        protected void OnPropertyChanged(string propertyName)
        {
            if (_propertyChanged != null)
            {
                _propertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }

        /// <summary>
        /// Occurs when a property value changes
        /// </summary>
        public event PropertyChangedEventHandler PropertyChanged
        {
            add
            {
                _propertyChanged += value;
            }
            remove
            {
                _propertyChanged -= value;
            }
        }
        #endregion INotifyPropertyChanged implementation

    }

}
